package com.handz.test.Interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 应用模块名称<p>
 *
 * @author hepeiyun
 * @since 2019/11/5
 */
@Slf4j
public class ReqInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("preHandle is running！");
        if (handler instanceof HandlerMethod) {
            HandlerMethod h = (HandlerMethod) handler;
            log.info("bean:{}", h.getBean());
            log.info("method:{}", h.getMethod());
            log.info("params:{}", h.getMethodParameters());
        }
        return true;
    }
}
